package org.penguin.study.bk.web.listener;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;

@Slf4j
@WebListener
public class SimpleServletContextListener implements ServletContextListener, HttpSessionListener, HttpSessionAttributeListener {

    public SimpleServletContextListener() {
    }

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        log.info("侦听器：上下文环境已初始化");
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        log.info("侦听器：上下文环境被销毁");
    }

    @Override
    public void sessionCreated(HttpSessionEvent se) {
        log.info("侦听器：会话已创建");
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        log.info("侦听器：会话被销毁");
    }

    @Override
    public void attributeAdded(HttpSessionBindingEvent sbe) {
        log.info("侦听器：加入属性");
    }

    @Override
    public void attributeRemoved(HttpSessionBindingEvent sbe) {
        log.info("侦听器：属性被删除");
    }

    @Override
    public void attributeReplaced(HttpSessionBindingEvent sbe) {
        log.info("侦听器：属性被修改");
    }
}
